﻿CREATE PROCEDURE [dbo].[Hogar_ParteDiarioPersonal_ObtenerPorMesQuincenaAgente]
	@Mes INT,
	@Año INT,
	@Quincena INT,
	@AgenteId INT
AS
BEGIN
	DECLARE @ParteQuincenalPersonalId INT

	SELECT  @ParteQuincenalPersonalId = [ParteQuincenalPersonalId]
	FROM [dbo].[ParteQuincenalPersonal] WITH (NOLOCK)
	WHERE [Mes] = @Mes AND [Quincena] = @Quincena AND [Año] = @Año

	SELECT [ParteDiarioPersonalId],
	[AgenteId],
	[DiaJustificar],
	[PeriodoDesde],
	[PeriodoHasta],
	[Observaciones],
	[CodigoAusentismoId],
	[ParteQuincenalPersonalId],
	CASE WHEN [Activo] = 1 THEN 1 ELSE 0 END AS [Activo]
	FROM [dbo].[ParteDiarioPersonal] WITH (NOLOCK)
	WHERE [ParteQuincenalPersonalId] = @ParteQuincenalPersonalId AND [AgenteId] = @AgenteId AND [Activo] = 1
END
